/* 
  聊天记录数据库 
  */
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose'
import mongoose, { Document } from 'mongoose'
export type chatDocument = Chat & Document

@Schema({ timestamps: true })
class Chat {
  @Prop({ required: true, ref: 'User' })
  //发信人
  send: mongoose.Types.ObjectId

  @Prop({ required: true, ref: 'User' })
  //聊天对象 接收者
  receive: mongoose.Types.ObjectId

  //消息主体
  @Prop({ required: true })
  content: string
}

const chatSchema = SchemaFactory.createForClass(Chat)

export { Chat, chatSchema }
